package com.h3c.ptability.utils;

import cn.hutool.core.util.PageUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

/**
 * @author chenyifan
 * @date 2022/5/27 10:03
 */
public class PageUtils extends PageUtil {
    /**
     * 生成mybatis分页对象
     * @param page
     * @param records
     * @param <T>
     * @return
     */
    public static <T> Page<T> toPage(IPage<?> page, List<T> records) {
        Page<T> pageResult = new Page();
        pageResult.setCurrent(page.getCurrent());
        pageResult.setSize(page.getSize());
        pageResult.setPages(page.getPages());
        pageResult.setTotal(page.getTotal());
        pageResult.setRecords(records);
        return pageResult;
    }
}
